package com.webflux.dmeo.functionCompileDemo;

import java.util.function.Consumer;
import java.util.function.IntPredicate;
import java.util.function.Predicate;

/**
 * Created by wangzhanjin on 2018/5/31.
 */
public class FunctionDemo {
    public static void main(String[] args) {
        //断言函数接口
        Predicate<Integer> predicate = i -> i > 0;
        IntPredicate intPredicate = i -> i > 0;
        System.out.println(predicate.test(-9));
        System.out.println(predicate.test(9));
        // 最好使用自带类型的函数接口Predicate，这样不用写泛型了
        System.out.println(intPredicate.test(9));

        //消费函数接口，自带IntConsumer，
        Consumer<String> consumer = s -> System.out.println(s);
        consumer.accept("输入的数据是");
    }
}
